#ifndef SERVERTCP_H
#define SERVERTCP_H
#include <QTcpServer>
#include <tcpsocket.h>
#include <client_server.h>
#include "server_main.h"
class ServerTcp : QTcpServer
{
    Q_OBJECT
public:
    static ServerTcp* gethand()
    {
        if(global_server == nullptr)
            global_server = new ServerTcp();
        return global_server;
    }
    void Start();
    void Stop();
private:

    explicit ServerTcp();
    virtual void incomingConnection(qintptr handle) override;
public slots:
    void slot_sockdisconnected(TcpSocket* sock);
    void slot_sockdata(TcpSocket* sock);
    void slot_writedata(TcpSocket *Sock , QByteArray data);
signals:
void sig_sockdisconnect(TcpSocket *Sock);
void sig_getdata(TcpSocket *Sock);
void sig_write(TcpSocket *Sock , QByteArray data);
public:
    static ServerTcp* global_server;

private:
};

#endif // SERVERTCP_H
